
public class Particle {
	 private Position location;
	 private Velocity velocity;
	 private double fitness;

	 


	public void setFitness(double fitness) {
		this.fitness = fitness;
	}


	 
	 public double getFitness() {
	 calculateFitness();
	 return fitness;
	 }
	 
	 public void calculateFitness() {
	 double x = this.location.getX();
	 double y = this.location.getY();
	 
	 if(Main.funtion1){
		 fitness = Math.pow((2.8125 - x + x * Math.pow(y, 4)), 2) +
		 Math.pow((2.25 - x + x * Math.pow(y, 2)), 2) +
		 Math.pow((1.5 - x + x * y), 2);
		 //To get the pBest always to calculate the new fitness
	 }else{
		 fitness =  (4 - 2.1 *Math.pow(x, 2) +  Math.pow(x, 4)/3 )*Math.pow(x, 2) + (x* y) + ( - 4  +  4*Math.pow(y, 2))* Math.pow(y, 2); 
	 }
	 }
	 
	 public Position getLocation() {
	 return location;
	 }
	 
	 public void setLocation(Position location) {
	 this.location = location;
	 }
	 
	 public Velocity getVelocity() {
	 return velocity;
	 }
	 
	 public void setVelocity(Velocity velocity) {
	 this.velocity = velocity;
	 }
	}